//
//  MusicDetailCollectionViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/22.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "MusicDetailCollectionViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>

@interface MusicDetailCollectionViewCell()

@property(nonatomic, retain) UIImageView *imageview;

@property(nonatomic, retain) UILabel *label;

@property(nonatomic, retain) UILabel *perLabel;

@end

@implementation MusicDetailCollectionViewCell

- (void)dealloc
{
    [_detailModel release];
    [_imageview release];
    [_label release];
    [_perLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageview = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageview];
        [_imageview release];
        
        self.label = [[UILabel alloc]init];
        self.label.font = [UIFont systemFontOfSize:15 * kWidth];
        self.label.textColor = [UIColor blackColor];
        [self.contentView addSubview:self.label];
        [_label release];
        
        self.perLabel = [[UILabel alloc]init];
        self.perLabel.font = [UIFont systemFontOfSize:15 * kWidth];
        self.perLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.perLabel];
        [_perLabel release];

    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.imageview.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 50 * kHeight);
    self.label.frame = CGRectMake(0, self.frame.size.height - 45 * kHeight, self.frame.size.width, 20 * kHeight);
    self.perLabel.frame = CGRectMake(0, self.frame.size.height - 25 * kHeight, self.frame.size.width, 20 * kHeight);
}

-(void)setDetailModel:(MusicDetailModel *)detailModel
{
    if (_detailModel != detailModel) {
        [_detailModel release];
        _detailModel = [detailModel retain];
    }
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:detailModel.pic_200] placeholderImage:[UIImage imageNamed:@"placeHoder"]];
    self.label.text = detailModel.name;
    self.perLabel.text = [detailModel.User objectForKey:@"name"];
}

@end
